

class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;

    TreeNode() {
    }

    TreeNode(int val) {
        this.val = val;
    }

    TreeNode(int val, TreeNode left, TreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }
}

public class Test1 {
    public boolean isUnivalTree(TreeNode root) {
        if (root == null) return true;
        if (root.val == root.left.val || root.val == root.right.val) {
            isUnivalTree(root.left);
            isUnivalTree(root.right);
        } else {
            return false;
        }
        return true;
    }

    public int removeElement(int[] nums, int val) {
        int k = 0; // 记录不等于 val 的元素的位置
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != val) { // 如果当前元素不等于 val
                nums[k] = nums[i]; // 将当前元素赋值给 nums[k]
                k++; // k 指针后移
            }
        }
        return k; // 返回不等于 val 的元素的数量
    }




}
